import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  // {
  //   path: '/',
  //   name: 'home',
  //   component: HomeView
  // },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
  {
    path: "",
    redirect: "/login",
  },
  {
    path: "/login",
    component: () => import("../views/login.vue"),
  },
  {
    path: "/",
    component: () => import("../views/admin.vue"),
    children: [
      {
        path: "",
        redirect: "user",
      },
      {
        path: "user",
        component: () => import("../views/btm-right/user.vue"),
      },
      {
        path: "project",
        component: () => import("../views/btm-right/project.vue"),
      },
      {
        path: "datas",
        component: () => import("../views/btm-right/datas.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push;
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
export default router;
